// app.js
import api from './utils/api'
App({
  onLaunch() {
    wx.getSystemInfo({
      success: e => {
        this.globalData.StatusBar = e.statusBarHeight;
        let capsule = wx.getMenuButtonBoundingClientRect();
        if (capsule) {
          this.globalData.Custom = capsule;
          this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
        } else {
          wx.showModal({
            title: '提示',
            content: JSON.stringify(capsule),
            success(res) {
            }
          })
          this.globalData.CustomBar = e.statusBarHeight + 50;
        }
        this.globalData.windowHeight = e.windowHeight - e.statusBarHeight-this.globalData.CustomBar;//获取屏幕高度
      },
      fail:e => {
        console.log(e);
      }
    })
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // wx.switchTab({
        //   url: '/pages/task/task',
        // })
       // 发送 res.code 到后台换取 openId, sessionKey, unionId
        // api.login({Jscode : res.code}).then(res => {
        //   this.globalData.userInfo = res.data.data;
        //   if(res.data.data.id == null){
        //     wx.navigateTo({
        //       url:"/pages/signup/signup"
        //     })
        //   }else{
        //     wx.switchTab({
        //       url: '/pages/task/task',
        //     })
        //   }
        // })
      }
    })
  },
  globalData: {
    userInfo: null,
  },
  api:api
})
  